<%@ include file="include.jsp" %>
<div class="portal-add-content">
	<div class="control-panel-tools">
		<aui:input cssClass="search-panels" inputCssClass="search-panels-input" label="" name="searchPanel" />
	</div>

	<liferay-ui:panel-container extended="<%= true %>" id="controlPanelMenuAddContentPanelContainer" persistState="<%= true %>">

		<%
		String ppid = GetterUtil.getString((String)request.getAttribute("control_panel.jsp-ppid"), layoutTypePortlet.getStateMaxPortletId());

		String category = PortalUtil.getControlPanelCategory(ppid, themeDisplay);

		String[] allCategories = {"menu 1", "menu 2"};

		String controlPanelCategory = HttpUtil.getParameter(PortalUtil.getCurrentURL(request), "controlPanelCategory", false);

		if (Validator.isNotNull(controlPanelCategory)) {
			allCategories = new String[] {controlPanelCategory};
		}

		//String categoryPortletsContent = "categoryPortletsContent";
		for (String curCategory : allCategories) {
			String title = null;
			String icon = themeDisplay.getPathThemeImages() + "/common/site_icon.png";
			String curGroupName = "curGroupName";
			String url="url";
				%>
				<liferay-util:buffer var="groupSelectorIconMenu">
					<liferay-ui:icon-menu align="left" direction="down" icon="<%= icon %>" id="groupSelector" message="<%= HtmlUtil.escape(StringUtil.shorten(curGroupName, 25)) %>">
								<%
								for (int i = 0; i < 2; i++) {
									String image = "site_icon";
									String message = "meassage"+i;
									%>

									<liferay-ui:icon
										image="<%= image %>"
										message="<%= HtmlUtil.escape(message) %>"
										url="<%= url %>"
									/>

								<%
								}
								%>

							</liferay-ui:icon-menu>
								<liferay-ui:staging cssClass="manage-pages-branch-menu" extended="<%= true %>" groupId="13718" icon="/common/tool.png" showManageBranches="<%= false %>" />

							<%
							String image = "site";
							%>

							<liferay-ui:icon
								cssClass="lfr-panel-title-single"
								image="<%= image %>"
								label="<%= true %>"
								message="<%= HtmlUtil.escape(StringUtil.shorten(curGroupName, 25)) %>"
							/>
				</liferay-util:buffer>

		<%
				title = groupSelectorIconMenu;
			}
		%>

			<liferay-util:buffer var="categoryPortletsContent">
					<div class="nobr lfr-title-scope-selector">
						<liferay-ui:icon-menu align="left" direction="down" icon="" message='<%= LanguageUtil.get(pageContext, "scope") + StringPool.COLON + StringPool.SPACE + "curGroupLabel" %>'>
							<liferay-ui:icon
								image="folder"
								message="default"
								url='<%= HttpUtil.setParameter(PortalUtil.getCurrentURL(request), "doAsGroupId", 1) %>'
							/>

							<%
							for (int j = 0; j < 2; j++) {
								String m = "messa"+j;
								String u = "urltest"+j;
							%>

								<liferay-ui:icon
									image="folder"
									message="<%=m %>"
									url='<%= u %>'
								/>

							<%
							}
							%>

						</liferay-ui:icon-menu>
					</div>

				<ul class="category-portlets">

					<%
					for (int k=0; k < 2; k++) {
						%>

							<li class="<%= k==1 ? "selected-portlet" : "" %>">
								<a href="<liferay-portlet:renderURL doAsGroupId="<%= themeDisplay.getScopeGroupId() %>" portletName="NAME>" windowState="<%= WindowState.MAXIMIZED.toString() %>" />" id="<portlet:namespace />portlet_<%= k %>">
									<liferay-ui:icon src='<%= themeDisplay.getPathContext() + "/html/icons/default.png" %>' />
									<%= "abc"+k %>
								</a>
							</li>

					<%
					}
				%>

				</ul>
			</liferay-util:buffer>

			<c:choose>
				<c:when test="<%= Validator.isNotNull(controlPanelCategory) %>">
					<div class="lfr-panel-container" id="controlPanelMenuAddContentPanelContainer">
						<div class="lfr-panel lfr-component panel-page-category lfr-extended" id="panel-manage-content">
							<div class="lfr-panel-content">

								<%= categoryPortletsContent %>

							</div>
						</div>
					</div>
				</c:when>
				<c:otherwise>
					<liferay-ui:panel collapsible="<%= true %>" cssClass="lfr-component panel-page-category" extended="<%= true %>" id='<%= "panel-manage-" + "curCategory" %>' persistState="<%= true %>" title='<%= "title" %>'>

						<%= categoryPortletsContent %>

					</liferay-ui:panel>
				</c:otherwise>
			</c:choose>

	</liferay-ui:panel-container>
</div>

<aui:script use="liferay-panel">
	var trigger = A.one('#<portlet:namespace />groupSelector a');

	var panelContainer = Liferay.Panel.get('controlPanelMenuAddContentPanelContainer');

	if (trigger && panelContainer) {
		trigger.on(
			'click',
			function(event) {
				panelContainer.once(
					'collapse',
					function(event) {
						event.preventDefault();
					}
				);
			}
		);
	}
</aui:script>